﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using com.google.zxing;
using com.google.zxing.common;
using com.google.zxing.qrcode;
using System.Windows.Media.Imaging;
using System.IO.IsolatedStorage;
using System.IO;
using System.Windows.Media;
using Microsoft.Xna.Framework.Media;
using MicroMsg.sdk;
using Microsoft.Phone.Tasks;
using System.Threading.Tasks;
using Windows.Phone.Storage.SharedAccess;
using Windows.Storage;
using ScannerDemo;

namespace ScannerDemo
{
    public partial class share_info : PhoneApplicationPage
    {
        string tempString = "";
        public share_info()
        {
            InitializeComponent();
        }


        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if ((NavigationContext.QueryString.Count > 0))
            {
                NavigationContext.QueryString.TryGetValue("text", out tempString);
            }

        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string AppID = "wx124d4f2786d28ebc";
            int scene = SendMessageToWX.Req.WXSceneChooseByUser;
            WXBaseMessage message = null;

            MemoryStream ms = new MemoryStream();
            byte[] bytes = ms.GetBuffer();  


                WXTextMessage msg = new WXTextMessage();
                msg.Title = "文本";
                //msg.Description = "这是一个文本";
                //msg.ThumbData = jpg;
                msg.Text = tempString;
                message = msg;
            try
            {
                SendMessageToWX.Req req = new SendMessageToWX.Req(message, scene);
                IWXAPI api = WXAPIFactory.CreateWXAPI(AppID);
                api.SendReq(req);
            }
            catch (WXException ex)
            {
                MessageBox.Show(ex.Message);
                //MessageBox.Show("mmm");
            }
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            SmsComposeTask sendSMS = new SmsComposeTask();
            sendSMS.Body = tempString;
            sendSMS.Show();
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            EmailComposeTask sendEmail = new EmailComposeTask();
            sendEmail.Body = tempString;
            sendEmail.Show();
        }
    }
}